package cn.toutatis.sandbox.root.config;

import org.springframework.boot.web.server.ErrorPage;
import org.springframework.boot.web.server.ErrorPageRegistrar;
import org.springframework.boot.web.server.ErrorPageRegistry;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpStatus;

/**
 * 错误页配置
 * @author Toutatis_Gc
 * @since 2020-1-7 Gc
 */
@Configuration
public class ErrorPageConfig implements ErrorPageRegistrar {

    @Override
    public void registerErrorPages(ErrorPageRegistry registry) {
        ErrorPage error404 = new ErrorPage(HttpStatus.NOT_FOUND,"/errorInfo?code=404");
        ErrorPage error500 = new ErrorPage(HttpStatus.INTERNAL_SERVER_ERROR,"/errorInfo?code=500");
        //通用配置页
        ErrorPage simpleErrorPage = new ErrorPage("/errorInfo");
        registry.addErrorPages(error404,error500,simpleErrorPage);
    }
}
